// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "CaeVirtualDeviceConfig.h"
#include "../cae_CPHMediaEngine/CPHMediaEngine.h"

//本地仿真设备数据注入文件路径
static const char* CAMERA_STREAM_H264_FILE_PATH = "/data/cloudAppEngine/camera.h264";
static const char* CAMERA_STREAM_YUV_FILE_PATH = "/data/cloudAppEngine/camera.yuv";
static const char* CAMERA_STREAM_JPEG_FILE_PATH = "/data/cloudAppEngine/camera.jpg";
static const char* MICROPHONE_STREAM_PCM_FILE_PATH = "/data/cloudAppEngine/microphone.pcm";

//仿真设备本地读取文件类型
static const uint32_t LOCAL_CAMERA_STREAM_INJECT_FILE_TYPE = VMI_H264;
static const uint32_t LOCAL_MICROPHONE_STREAM_INJECT_FILE_TYPE = VMI_PCM;

bool CaeVirtualDeviceConfig::isOpenCameraFlag = false;
bool CaeVirtualDeviceConfig::isOpenMicrophoneFlag = false;
MSG_HEADER *CaeVirtualDeviceConfig::cameraTmpHeader = nullptr;
uint8_t *CaeVirtualDeviceConfig::cameraTmpData = nullptr;
CaePipeData *CaeVirtualDeviceConfig::cameraTmpPipeData = nullptr;
MSG_HEADER *CaeVirtualDeviceConfig::microphoneTmpHeader = nullptr;
uint8_t *CaeVirtualDeviceConfig::microphoneTmpData = nullptr;
CaePipeData *CaeVirtualDeviceConfig::microphoneTmpPipeData = nullptr;

const char* &CaeVirtualDeviceConfig::GetCameraStreamH264FilePath()
{
    return CAMERA_STREAM_H264_FILE_PATH;
}

const char* &CaeVirtualDeviceConfig::GetCameraStreamYuvFilePath()
{
    return CAMERA_STREAM_YUV_FILE_PATH;
}

const char* &CaeVirtualDeviceConfig::GetCameraStreamJpegFilePath()
{
    return CAMERA_STREAM_JPEG_FILE_PATH;
}

const char* CaeVirtualDeviceConfig::GetMicrophoneStreamPcmFilePath()
{
    return MICROPHONE_STREAM_PCM_FILE_PATH;
}

uint32_t CaeVirtualDeviceConfig::GetLocalCameraStreamInjectFileType()
{
    return LOCAL_CAMERA_STREAM_INJECT_FILE_TYPE;
}

uint32_t CaeVirtualDeviceConfig::GetLocalMicrophoneStreamInjectFileType()
{
    return LOCAL_MICROPHONE_STREAM_INJECT_FILE_TYPE;
}

bool CaeVirtualDeviceConfig::IsOpenCamera() {
    return isOpenCameraFlag;
}

void CaeVirtualDeviceConfig::SetOpenCameraFlag(bool isOpenCamera, MSG_HEADER *header, uint8_t *data, CaePipeData *pipeData) {
    isOpenCameraFlag = isOpenCamera;
    cameraTmpData = data;
    cameraTmpHeader = header;
    cameraTmpPipeData = pipeData;
}

bool CaeVirtualDeviceConfig::IsOpenMicrophone() {
    return isOpenMicrophoneFlag;
}

void CaeVirtualDeviceConfig::SetOpenMicrophoneFlag(bool isOpenMicrophone, MSG_HEADER *header, uint8_t *data, CaePipeData *pipeData) {
    isOpenMicrophoneFlag = isOpenMicrophone;
    microphoneTmpData = data;
    microphoneTmpHeader = header;
    microphoneTmpPipeData = pipeData;
}

MSG_HEADER *CaeVirtualDeviceConfig::GetCameraTmpHeader() {
    return cameraTmpHeader;
}

uint8_t *CaeVirtualDeviceConfig::GetCameraTmpData() {
    return cameraTmpData;
}

CaePipeData *CaeVirtualDeviceConfig::GetCameraTmpPipeData() {
    return cameraTmpPipeData;
}

MSG_HEADER *CaeVirtualDeviceConfig::GetMicrophoneTmpHeader() {
    return microphoneTmpHeader;
}

uint8_t *CaeVirtualDeviceConfig::GetMicrophoneTmpData() {
    return microphoneTmpData;
}

CaePipeData *CaeVirtualDeviceConfig::GetMicrophoneTmpPipeData() {
    return microphoneTmpPipeData;
}
